package mia.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateManager {

	static private Configuration cfg;
	static private ServiceRegistry svRegistry;
	static private SessionFactory sessionFactory;
	
	static{
		cfg = new Configuration().configure();
		svRegistry = new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry();
		sessionFactory = cfg.buildSessionFactory(svRegistry);
	}
	
	public static Session getSession()
	{
		return sessionFactory.openSession();
	}
}
